package icu.shaoyayu.common.web.exception;


import icu.shaoyayu.common.utll.R;
import icu.shaoyayu.common.utll.ReturnUtil;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author shaoyayu
 * @date 2021/12/22
 * @apiNote
 */
@RestControllerAdvice
public class RestExceptionHandler {
    /**
     * 默认全局异常处理。
     * @param e the e
     * @return ResultData
     */
    @ExceptionHandler(Exception.class)
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public R<String> exception(Exception e) {
        // TODO 全局异常处理
        return ReturnUtil.error(500,e.getMessage());
    }
}
